Skip to content

Implement(60881): Added detailed diagnostic for parent to child assignment#61145

Closed
NamHaiBui wants to merge 32 commits intomicrosoft:mainfrom
SeniorSeminarGroup:60881
Closed

Implement(60881): Added detailed diagnostic for parent to child assignment#61145
NamHaiBui wants to merge 32 commits intomicrosoft:mainfrom
SeniorSeminarGroup:60881

Conversation

@NamHaiBui
Copy link

@NamHaiBui NamHaiBui commented Feb 7, 2025

Fixes #60881

@NamHaiBui
Copy link
Author

@microsoft-github-policy-service agree

@RolandLocke
Copy link

This newest change will fail the CI tests. However, it should correctly add the message we are looking for. I didn't accept the baseline so we can perform the difference checker in class tomorrow and ensure the new message is correct.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Feb 19, 2025
@NamHaiBui NamHaiBui marked this pull request as ready for review February 19, 2025 02:30
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Feb 19, 2025
@NamHaiBui NamHaiBui changed the title 60881 Implement(60881): Added detailed diagnostic for parent to child assignment Feb 21, 2025
@jakebailey
Copy link
Member

This PR contains a bunch of unrelated formatting changes which make this PR hard to review; you should revert these. If you have auto-format enabled in your editor, make sure it's running dprint.

@RolandLocke
Copy link

This PR contains a bunch of unrelated formatting changes which make this PR hard to review; you should revert these. If you have auto-format enabled in your editor, make sure it's running dprint.

@jakebailey I've removed the formatting issues. Please let us know if there are any additional changes to be made.

@RolandLocke
Copy link

@jakebailey Can you take another look at this issue? I think its ready for review.

@github-project-automation github-project-automation bot moved this from Not started to Waiting on author in PR Backlog Apr 16, 2025
conditionalTypes2.ts(15,5): error TS2322: Type 'Covariant<A>' is not assignable to type 'Covariant<B>'.
Type 'A' is not assignable to type 'B'.
'B' could be instantiated with an arbitrary type which could be unrelated to 'A'.
'B' is constrained to be a subtype of 'A'.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not understanding why this error message is an improvement. What's the smallest example where this error is going to be easier to understand?

Copy link

@Alexandrialexie Alexandrialexie Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RyanCavanaugh This error message is an improvement because the original error message says that the two types could be unrelated but we know they are related in a parent child relationship, you just can't assign a parent to a child. We tried to pick a new error message that was similar to the suggestion in the original issue. This is the simplest example we looked at:

function example<SuperType, SubType extends SuperType>(superType: SuperType, subType: SubType) {
  subType = superType;
}

@github-project-automation github-project-automation bot moved this from Waiting on author to Done in PR Backlog Mar 24, 2026
@typescript-bot
Copy link
Collaborator

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

misleading error message on invalid assignment when one type parameter extends another

8 participants